package com.czk.webflux.handler.client;

import com.czk.webflux.entity.User;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;

/**
 * @Author:ChenZhangKun
 * @Date: 2020/11/26 22:11
 */
public class Client {
    public static void main(String[] args) {
        WebClient webClient = WebClient.create("http://127.0.0.1:64033");

        // 根据id查询
        String id = "1";
        Mono<User> userMono = webClient.get().uri("/users/{id}", id).accept(MediaType.APPLICATION_JSON).retrieve().bodyToMono(User.class);
        User user = userMono.block();
        System.out.println(user);
    }
}
